package com.zxbit.uangstore.view;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.zxbit.uangstore.R;
import com.zxbit.uangstore.base.ILoading;

public class LoadingDialog extends Dialog implements ILoading {
    public LoadingDialog(@NonNull Context context) {
        super(context);
        initViews(context);
    }

    public LoadingDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        initViews(context);
    }

    protected LoadingDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        initViews(context);
    }

    private void initViews(Context context) {
        ViewGroup rootView = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.dialog_loading_layout,null);
        setContentView(rootView);

        setCancelable(false);
        setCanceledOnTouchOutside(false);
    }

    @Override
    public void showLoading() {
        show();
    }

    @Override
    public void dismissLoading() {
        dismiss();
    }
}
